import { reactive, toRefs } from 'vue';
export const useTableNoPage = (api, initParams) => {
  const state = reactive({
    tableData: [],
    tableLoading: false,
    searchForm: {
      ...initParams
    }
  });

  const search = () => {
    getList();
  };
  const getList = async () => {
    state.tableLoading = true;
    try {
      const res = await api(state.searchForm);
      state.tableData = res.data;
      state.tableLoading = false;
    } catch (e) {
      // console.log(e);
    }
  };

  return {
    ...toRefs(state),
    search,
    getList
  };
};
